/*
 * Copyright (C) 2008 CERNET Network Center 
 * dvping/dvmcast/hdvping/hdvmcast series 
 * 
 * Design and coding: 
 *  	Xing Li <xing@cernet.edu.cn> 
 *	Congxiao Bao <congxiao@cernet.edu.cn>
 * 	Jinpeng Jiang <jjp02@mails.tsinghua.edu.cn>
 * 
 * Contributions:
 * 
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 */

#include "DestSpecDVDestination.h"

DestSpecDVDestination::DestSpecDVDestination(const IPAddress& addr, in_port_t port, int32_t log_period /*= 0*/) : dest_ep(addr, port)
{
	sock = Socket::CreateUdpSender(addr.AddressFamily());
}

DestSpecDVDestination::~DestSpecDVDestination()
{
	sock.Close();
}
bool DestSpecDVDestination::Init()
{
	return true;
}
bool DestSpecDVDestination::DealPacket(char* packet, int length, const IPEndPoint&/* ep*/)
{
	if(packet == NULL || length < 4)
		return false;
	sockaddr_in6 addr;
	dest_ep.FillSockAddr(addr);
	return sendto(sock.Handle(), packet, length, 0, (sockaddr*)&addr, sizeof(addr)) == length;
}

